package com.ruoyi.web.controller.basicInformation;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.basicInformation.vo.TTravelAlarmVo;
import com.ruoyi.system.basicInformation.bo.TTravelAlarmQueryBo;
import com.ruoyi.system.basicInformation.bo.TTravelAlarmAddBo;
import com.ruoyi.system.basicInformation.bo.TTravelAlarmEditBo;
import com.ruoyi.system.basicInformation.service.ITTravelAlarmService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 旅游报警信息Controller
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@Api(value = "旅游报警信息控制器", tags = {"旅游报警信息管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/basicInformation/travelAlarm")
public class TTravelAlarmController extends BaseController {

    private final ITTravelAlarmService iTTravelAlarmService;

    /**
     * 查询旅游报警信息列表
     */
    @ApiOperation("查询旅游报警信息列表")
    @PreAuthorize("@ss.hasPermi('basicInformation:travelAlarm:list')")
    @GetMapping("/list")
    public TableDataInfo<TTravelAlarmVo> list(TTravelAlarmQueryBo bo) {
        startPage();
        List<TTravelAlarmVo> list = iTTravelAlarmService.queryList(bo);
        return getDataTable(list);
    }
    /**
     * 查询旅游报警信息列表
     */
    @ApiOperation("查询旅游报警信息列表--map")
    @GetMapping("/listForMap")
    public TableDataInfo<TTravelAlarmVo> listForMap(TTravelAlarmQueryBo bo) {
        startPage();
        List<TTravelAlarmVo> list = iTTravelAlarmService.queryList(bo);
        return getDataTable(list);
    }
    /**
     * 导出旅游报警信息列表
     */
    @ApiOperation("导出旅游报警信息列表")
    @PreAuthorize("@ss.hasPermi('basicInformation:travelAlarm:export')")
    @Log(title = "旅游报警信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<TTravelAlarmVo> export(TTravelAlarmQueryBo bo) {
        List<TTravelAlarmVo> list = iTTravelAlarmService.queryList(bo);
        ExcelUtil<TTravelAlarmVo> util = new ExcelUtil<TTravelAlarmVo>(TTravelAlarmVo.class);
        return util.exportExcel(list, "旅游报警信息");
    }

    /**
     * 获取旅游报警信息详细信息
     */
    @ApiOperation("获取旅游报警信息详细信息")
    @PreAuthorize("@ss.hasPermi('basicInformation:travelAlarm:query')")
    @GetMapping("/{id}")
    public AjaxResult<TTravelAlarmVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iTTravelAlarmService.queryById(id));
    }

    /**
     * 新增旅游报警信息
     */
    @ApiOperation("新增旅游报警信息")
    @PreAuthorize("@ss.hasPermi('basicInformation:travelAlarm:add')")
    @Log(title = "旅游报警信息", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody TTravelAlarmAddBo bo) {
        return toAjax(iTTravelAlarmService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 新增旅游报警信息
     */
    @ApiOperation("新增旅游报警信息")
    @Log(title = "旅游报警信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult<Void> addData(@RequestBody TTravelAlarmAddBo bo) {
        return toAjax(iTTravelAlarmService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改旅游报警信息
     */
    @ApiOperation("修改旅游报警信息")
    @PreAuthorize("@ss.hasPermi('basicInformation:travelAlarm:edit')")
    @Log(title = "旅游报警信息", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody TTravelAlarmEditBo bo) {
        return toAjax(iTTravelAlarmService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除旅游报警信息
     */
    @ApiOperation("删除旅游报警信息")
    @PreAuthorize("@ss.hasPermi('basicInformation:travelAlarm:remove')")
    @Log(title = "旅游报警信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iTTravelAlarmService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
